/**
 * @format
 * @Author: TC
 * @Date: 2025-09-13 21:16:06
 * @Last Modified by: TC (tengchao@taqu.cn)
 * @Last Modified time: 2025-10-20 16:26:56
 */

import { _decorator, Node, tween, v3 } from "cc";
import { app } from "db://assets/FrameWork/App";
import { BaseUI } from "db://assets/FrameWork/Module/Component/BaseUI";
import { nsMoleEnum } from "../../Const/MoleEunm";
import { EMoleUIConst } from "../../Const/MoleUIConst";
import { gameMole } from "../../GameMole";
const { ccclass, property } = _decorator;

/**
 * 准备界面
 */
@ccclass("MolePrepareUI")
export class MolePrepareUI extends BaseUI {
    @property({ type: Node, displayName: "传统按钮" })
    private btnNormal: Node = null;
    @property({ type: Node, displayName: "道具按钮" })
    private btnProp: Node = null;
    @property({ type: Node, displayName: "商店按钮" })
    private btnShop: Node = null;
    @property({ type: Node, displayName: "关闭按钮" })
    private btnClose: Node = null;

    protected init(): void {
        super.init();
    }

    protected addUIEvent(): void {
        super.addUIEvent();
        this.addClickEvent(this.btnNormal, this._onNormal);
        this.addClickEvent(this.btnProp, this._onProp);
        this.addClickEvent(this.btnShop, this._onShop);
        this.addClickEvent(this.btnClose, this._onClose);
    }

    /**
     * 点击传统模式
     */
    private _onNormal(): void {
        gameMole.dataMgr.gameModle = nsMoleEnum.EGameModle.NORMAL;
        this._enterBattle();
    }

    /**
     * 点击道具模式
     */
    private _onProp(): void {
        gameMole.dataMgr.gameModle = nsMoleEnum.EGameModle.PROP;
        this._enterBattle();
    }

    /**
     * 进入战斗
     */
    private _enterBattle(): void {
        gameMole.dataMgr.initData();
        this.closeUI();
        app.uiMgr.openUI(EMoleUIConst.BattleUI);
    }

    /**
     * 点击商城
     */
    private _onShop(): void {
        this.closeUI();
        app.uiMgr.openUI(EMoleUIConst.ShopUI);
    }

    /**
     * 点击关闭
     */
    private _onClose(): void {
        this.closeUI();
    }
}
